import React from 'react'
import { Table, Button, Tag } from 'antd';
import { PoweroffOutlined, SyncOutlined, HeartTwoTone } from '@ant-design/icons';
import {store} from '../../../store'
import style from './audit-list.module.css'

export default function List(props) {
const dataSource = store.getState().toExamineList
const columns = [
  {
    title: '新闻标题',
    dataIndex: 'note',
    key: 'note',
  },
  {
    title: '作者',
    dataIndex: 'author',
    key: 'author',
  },
  {
    title: '新闻分类',
    dataIndex: 'gender',
    key: 'gender',
  },
  {
    title: '审核状态',
    dataIndex: 'audioState',
    key: 'audioState',
    render(text) {
      return tagFilter(text)
    },
  },
  {
    title: '操作',
    key: 'ccccc',
    align: 'center',
    render(text, item) {
      return (
        <div className={style.btnList}>
          <Button type="default" danger icon={<PoweroffOutlined />}>撤销</Button>
          <Button type="primary" icon={<SyncOutlined spin />}>发布</Button>
          <Button 
            type="dashed" 
            icon={<HeartTwoTone twoToneColor="#eb2f96" />}
            onClick={() => handleUpdate(item)}
          >更新</Button>
        </div>
      )
    }
  }
];
function handleUpdate(val) {
  props.history.push(`/news-manage/update/${val.roleId}`)
}
function tagFilter(val) {
  if (val === 1) {
    return (
      <Tag color="magenta">未通过</Tag>
    )
  }
}
  return (
    <div>
      <Table 
        dataSource={dataSource} 
        columns={columns}
        rowKey={item => item.roleId} 
      />;
    </div>
  )
}
